package com.extension.company.view.home.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.extension.company.admin.R;
import com.extension.company.model.api.RetrofitUrlApi;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者:zwk
 * 联系方式：497981239@qq.com
 * 时间：on 2019/7/30 22:12
 * 功能：
 */
public class CommentItemImgeAdapter extends RecyclerView.Adapter<CommentItemImgeAdapter.CommentItemIamgeViewHolder> {

	private Context context;
	private String[] commentImg;

	public CommentItemImgeAdapter(Context context, String[] commentImg) {
		this.context = context;
		this.commentImg = commentImg;
	}

	@NonNull
	@Override
	public CommentItemIamgeViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
		View view = LayoutInflater.from(context).inflate(R.layout.comment_item_img_item, viewGroup, false);
		return new CommentItemIamgeViewHolder(view);
	}

	@Override
	public void onBindViewHolder(@NonNull CommentItemIamgeViewHolder commentItemIamgeViewHolder, int i) {
		Log.d("zwk", "获取的图片地址" + commentImg[i]);
		if (null != commentImg[i]) {
//			RequestOptions requestOptions = new RequestOptions().centerCrop().transform(new RoundedCorners(5)); //
			Glide.with(context).load(RetrofitUrlApi.BaseHostUrl + commentImg[i]).into(commentItemIamgeViewHolder.childImage);
		}

	}

	@Override
	public int getItemCount() {
		Log.d("zwk",commentImg.length+"chagdu");
		return commentImg.length;
	}

	class CommentItemIamgeViewHolder extends RecyclerView.ViewHolder {
		@BindView(R.id.comment_child_img)
		ImageView childImage;

		public CommentItemIamgeViewHolder(@NonNull View itemView) {
			super(itemView);
			ButterKnife.bind(this, itemView);
		}
	}

}
